package com.lemon.boot.common.handler;

import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import java.io.ByteArrayInputStream;

/**
 * @author 李猛
 * @datetime 2024/8/9 17:26
 * @description TODO
 */
public class ServletInputStreamHandler extends ServletInputStream {
    private final byte[] body;

    public ServletInputStreamHandler(byte[] body) {
        this.body = body;
    }

    @Override
    public boolean isFinished() {
        return false;
    }

    @Override
    public boolean isReady() {
        return false;
    }

    @Override
    public void setReadListener(ReadListener listener) {

    }

    @Override
    public int read() {
        return new ByteArrayInputStream(body).read();
    }
}
